home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / p_stime.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  45 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / Set the pseudo-clock.
  8. oid process::stime(unsigned long t)
  9.  
  10.    if (debug) /*DELETE*/ cerr << "process" << this << "::stime(" << t << ")\n";
  11.    t_curtime = t;
  12.  
  13.    // skip past the beginning processes
  14.    for (process **pp = &t_runprocesses;
  15.  *pp && ((*pp)->t_desiredtime == 0);
  16.  pp = &(*pp)->t_next)
  17. if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", skipped\n"
  18. ;
  19.  
  20.    // move all passed-by processes to a safe place
  21.    process *saveprocs = 0;
  22.    while (*pp && ((*pp)->t_desiredtime <= t))
  23. {
  24. if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", saved\n";
  25. process *sv = *pp;
  26. process *svn = sv->t_next;
  27. *pp = svn;
  28. sv->t_next = saveprocs;
  29. saveprocs = sv;
  30. }
  31.  
  32.    // move the processes back onto the run queue
  33.    while (saveprocs)
  34. {
  35. if (debug) /*DELETE*/ cerr << "\t" << saveprocs << ", shuffled\n";
  36. process *sv = saveprocs;
  37. saveprocs = sv->t_next;
  38. sv->t_desiredtime = 0;
  39. sv->t_next = t_runprocesses;
  40. t_runprocesses = sv;
  41. shufflerunlist();
  42. }
  43.    if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::stime(" << t << ")\n";
  44.  
  45.